package com.example.myapplication

import ApiService
import android.app.Application
import android.content.Context
//import androidx.databinding.DataBindingComponent

import androidx.databinding.DataBindingUtil
import com.alibaba.android.arouter.launcher.ARouter

import com.drake.statelayout.StateConfig
import com.hjq.toast.ToastUtils
import com.tencent.mmkv.MMKV

class APP: Application() {

    companion object {
        @Volatile
        private var instance: APP? = null

        @JvmStatic
        fun getInstance() =
            instance ?: synchronized(this) {
                instance ?: APP().also { instance = it }
            }
    }

//    val mContext: Context = this

    override fun onCreate() {
        super.onCreate()
        initSDK()
    }

    //第三方库初始化
    private fun initSDK(){
        //打开日志
        ARouter.openLog()
        //打开调式
        ARouter.openDebug()
        //路由
        ARouter.init(this)
        //提示框初始化
        ToastUtils.init(this)
        //本地化存储
        MMKV.initialize(this)
        //接口
        ApiClient.getInstance().getService(ApiService::class.java)
        //缺省页全局配置
//        StateConfig.apply {
//            emptyLayout = R.layout.mult_state_empty // 配置全局的空布局
//            errorLayout = R.layout.mult_state_error // 配置全局的错误布局
//            loadingLayout = R.layout.mult_state_loading // 配置全局的加载中布局
//        }

        //DataBindingActivity
//        DataBindingUtil.setDefaultComponent(object : DataBindingComponent {
//            override fun getBindingAdapter(): BindingAdapter {
//                return BindingAdapter
//            }
//        })


    }

}